package org.gruposp2p.dnie.service.jpa;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.gruposp2p.dnie.model.DNIeDocumentToSign;
import org.gruposp2p.dnie.model.DNIeDocumentToSignOption;
import org.gruposp2p.dnie.service.DNIeDocumentToSignOptionDAO;
import org.springframework.stereotype.Repository;

/**
 *
 * @author jj
 */
@Repository("documentToSignOptionDao")
public class JpaDNIeDocumentToSignOptionDAO implements DNIeDocumentToSignOptionDAO{

    private EntityManager entityManager;

    @PersistenceContext
    public void setEntityManager(EntityManager entityManager) {
            this.entityManager = entityManager;
    }

    public DNIeDocumentToSignOption findById(Integer id) {
        return entityManager.find(DNIeDocumentToSignOption.class, id);
    }

    public DNIeDocumentToSignOption save(DNIeDocumentToSignOption entity) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void delete(Integer documentId) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<DNIeDocumentToSignOption> findByDocumentToSign(
            DNIeDocumentToSign dnieDocumentToSignId) {
    	List<DNIeDocumentToSignOption> result = null;
        Query query = entityManager.createQuery(
                "SELECT o FROM DNIeDocumentToSignOption o WHERE o.dnieDocumentToSignId = :dnieDocumentToSignId");
        query.setParameter("dnieDocumentToSignId", dnieDocumentToSignId);
        result = query.getResultList();
        return result;
    }

}
